<template>
  <div class="index">
    <div class="logo">温州非遗go</div>
    <van-search v-model="value" shape="round" background="transparent" placeholder="请输入搜索内容" @search="onSearch" />
    <div class="box" style="display: none;">
      <div class="box_list">
        <div class="box_list_item" v-for="item in shanhuList" :key="item.fyclassdataid"
          @click="toshxq(item.fyclassdataid)">
          <img :src="item.picurl" alt="">
          <div class="content">
            <div class="title">
              {{ item.shmc }}
            </div>
            <div class="depict" v-html="item.shjj"></div>
            <div class="tip">
              <span class="c_1">{{ item.codename }}</span>
              <span class="c_2">{{ item.areaname }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="more" @click="tosh()">
        <span>查看更多</span>
        <i></i>
      </div>
    </div>
    <div class="tabs">
      <van-tabs v-model="tabsActive" @click="onClick">
        <van-tab title="全部">
          <div class="s_name">非遗企业</div>
          <div class="fy_list">
            <div class="cont1" v-for="item in shanhuList" :key="item.fyclassdataid" @click="onFirm(item.fyclassdataid)">
              <img :src="item.picurl" alt="" />
              <div class="ri">
                <div class="ri1">
                  <div class="r11">{{ item.mc }}</div>
                  <div class="r12">
                    <van-tag color="#6CAAFE33" text-color="#6CAAFEFF">{{ item.leibiemc }}</van-tag>
                    <van-tag style="margin-left: 0.625rem" text-color="#D19C4F" color=" #FFD19C4F">{{ item.areaname
                    }}</van-tag>
                  </div>
                </div>
                <div class="ri2" v-html="item.jj"></div>
              </div>
            </div>
          </div>
          <van-empty class="custom-image" :image="empty" description="暂无数据" v-if="shanhuList <= 0" />
          <div class="se_more" @click="tosh()">
            <span>查看更多</span>
            <i></i>
          </div>
        </van-tab>
        <van-tab title="非遗企业">
          <div class="s_name">非遗企业</div>
          <div class="fy_list">
            <div class="cont1" v-for="item in shanhuList" :key="item.fyclassdataid" @click="onFirm(item.fyclassdataid)">
              <img :src="item.picurl" alt="" />
              <div class="ri">
                <div class="ri1">
                  <div class="r11">{{ item.mc }}</div>
                  <div class="r12">
                    <van-tag color="#6CAAFE33" text-color="#6CAAFEFF">{{ item.leibiemc }}</van-tag>
                    <van-tag style="margin-left: 0.625rem" text-color="#D19C4F" color=" #FFD19C4F">{{ item.areaname
                    }}</van-tag>
                  </div>
                </div>
                <div class="ri2" v-html="item.jj"></div>
              </div>
            </div>
          </div>
          <van-empty class="custom-image" :image="empty" description="暂无数据" v-if="shanhuList <= 0" />
          <div class="se_more" @click="tosh()" style="padding-bottom: 70px;">
            <span>查看更多</span>
            <i></i>
          </div>
        </van-tab>
        <van-tab title="非遗商品">
        </van-tab>
      </van-tabs>
      <div class="goods" v-if="bindGoods">
        <div class="top">
          <div class="title">非遗商品</div>
          <div class="more" @click="tosp()">
            <span>查看更多</span>
            <i></i>
          </div>
        </div>
        <section>
          <figure v-for="(item, index) in shanpinList" :key="item.RowNumber" @click="tospxq(item.fyclassdataid)">
            <img :src="item.picurl" alt="">
            <div class="goods_info">
              <div class="title">{{ item.mc }}</div>
              <div class="price">
                <em>￥</em>
                <span>{{ item.jiage }}</span>
              </div>
            </div>
          </figure>
        </section>
        <van-empty class="custom-image" :image="empty" description="暂无数据" v-if="shanpinList <= 0" />
      </div>
    </div>

  </div>
</template>

<script>
import { getqbList } from "@/api/api.js";
export default {
  name: '',
  data() {
    return {
      active: 0,
      tabsActive: 0,
      shanhuList: [],
      shanpinList: [],
      value: this.$route.query.value,
      bindGoods: true,
      empty: require("../../assets/images/empty.png")
    };
  },
  created() {
    this.searchList()
  },
  mounted() {

  },
  methods: {
    tosp() {
      this.$router.push({
        path: "/goods"
      })
    },
    tosh() {
      this.$router.push({
        path: "/merchant"
      })
    },
    onSearch() {
      
      this.shanhuList = []
      this.shanpinList = []
      this.searchList()
      this.value = ''
    },
    onFirm(id) {
      this.$router.push({
        path: "/merchantXq",
        query: {
          id: id
        }
      })
    },
    tospxq(id) {
      this.$router.push({
        path: "/goodsXq",
        query: {
          id: id
        }
      })
    },
    onClick(name, title) {
      console.log(name, title)
      this.tabsActive = name
      if (name == 1) {
        this.bindGoods = false
      } else {
        this.bindGoods = true
      }
      this.searchList()
    },
    async searchList() {
      let res = await getqbList({
        lx: this.tabsActive,
        pageIndex: 1,
        pageSize: 30,
        mc: this.value
      })
      console.log('res==', res);
      if (res.code == 200) {
        let list = res.data.list
        this.shanpinList = list.filter(obj => obj.lx == 2)
        this.shanhuList = list.filter(obj => obj.lx == 1)
      }
    },
    onChange(index) {
      console.log(index);
      if (index == 1) {
        this.$router.push({
          path: "/my"
        })
      }
    },
  },
}
</script>
<style scoped lang="scss">
.index {
  width: 100%;
  height: 100%;
  background: url('../../assets/images/bj.png') no-repeat;
  background-size: 100% 100%;

  .logo {
    font-size: 1rem;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #000000;
    line-height: 1.125rem;
    padding: 2.25rem 0 1.125rem 1.125rem;
  }

  ::v-deep .van-search__content {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #FFFFFF;
  }

  ::v-deep .van-search {
    padding: 0 1.125rem;
  }

  .box {
    margin-top: 2.875rem;

    .box_list {
      display: flex;
      justify-content: start;
      overflow-x: auto;
      padding: 0 .5625rem;

      .box_list_item {
        width: 19.9375rem;
        background: #fff;
        border-radius: .5rem;
        margin: 0 .5625rem;

        img {
          width: 19.9375rem;
          height: 9.6875rem;
          border-radius: .5rem .5rem 0 0;
        }

        .content {
          padding: 1.125rem 1.125rem .625rem 1.125rem;

          .title {
            font-size: 1rem;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #3D3D3D;
            line-height: 1.375rem;
            padding-bottom: .625rem;
          }

          .depict {
            font-size: .75rem;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #666666;
            line-height: 1.0625rem;
            word-break: break-all;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
          }

          .tip {
            margin-top: .875rem;

            span {
              font-size: .625rem;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              line-height: 14px;
              border-radius: .125rem;
              padding: .125rem .3125rem;
            }

            .c_1 {
              color: #6CAAFE;
              background: rgba(108, 170, 254, 0.2);
              margin-right: .5625rem;
            }

            .c_2 {
              color: #D19C4F;
              background: rgba(209, 156, 79, 0.2);
            }
          }
        }
      }
    }

    .more {
      margin-top: 1.625rem;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;

      span {
        font-size: .875rem;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #6CAAFE;
        // line-height: 1.25rem;
        padding-right: .3125rem;
      }

      i {
        width: .4375rem;
        height: .75rem;
        background: url('../../assets/images/arrows_1.png') no-repeat;
        background-size: 100% 100%;
        display: block;
      }
    }
  }

  .tabs {
    width: 100%;
    // height: 400px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFF 100%);
    border-radius: 1.25rem 1.25rem 0px 0px;
    margin-top: 1.25rem;

    ::v-deep .van-tabs__nav {
      background-color: transparent;

      .van-tab {
        -webkit-box-flex: inherit;
        -webkit-flex: inherit;
        flex: inherit;
        padding: 0 15px;
      }

      .van-tab--active {
        font-size: 1rem;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 1.375rem;
      }

      .van-tabs__line {
        position: absolute;
        bottom: 24px;
        left: 0;
        z-index: 1;
        width: 35px;
        height: 6px;
        background-color: #6CAAFE;
        border-radius: 3px;
        opacity: 0.8;
      }
    }

    .van-tab__pane {
      padding: 0 15px;
    }

    .s_name {
      font-size: 1rem;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 1.375rem;
      padding: 20px 0 15px 0;
    }

    .cont1 {
      display: flex;
      width: calc(100% - 1.5rem);
      padding: 0.75rem;
      background: #ffffff;
      box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
      border-radius: 0.5rem;
      margin-bottom: 0.75rem;

      img {
        width: 7.5rem;
        height: 5.625rem;
        border-radius: 0.5rem;
      }

      .ri {
        width: calc(100% - 8.5625rem);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding-left: 1.0625rem;

        .ri1 {
          width: 100%;

          .r11 {
            width: 100%;
            font-size: 1rem;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 1.375rem;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
          }

          .r12 {
            width: 100%;
            display: flex;
            padding-top: 0.375rem;
          }
        }

        .ri2 {
          width: 100%;
          font-size: 0.625rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #666666;
          line-height: 0.9375rem;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-line-clamp: 2;
          display: -webkit-box;
          -webkit-box-orient: vertical;
        }
      }
    }

    .se_more {
      margin-top: 1.625rem;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;

      span {
        font-size: .875rem;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #6CAAFE;
        // line-height: 1.25rem;
        padding-right: .3125rem;
      }

      i {
        width: .4375rem;
        height: .75rem;
        background: url('../../assets/images/arrows_1.png') no-repeat;
        background-size: 100% 100%;
        display: block;
      }
    }
  }

  .goods {
    margin-top: 1.375rem;
    padding-bottom: 5rem;

    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 1.125rem;

      .title {
        font-size: 1rem;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #000000;
        line-height: 1.5625rem;
      }

      .more {
        display: flex;
        align-items: center;
        justify-content: center;

        span {
          font-size: .75rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #333333;
          padding-right: .3125rem;
        }

        i {
          width: .4375rem;
          height: .75rem;
          background: url('../../assets/images/arrows_2.png') no-repeat;
          background-size: 100% 100%;
          display: block;
        }
      }
    }

    section {
      margin: 0 auto;
      overflow: hidden;
      column-count: 2;
      column-gap: 0;
      margin-top: .8125rem;
      padding: 0 .3125rem;
    }

    figure {
      margin: 0 .5625rem .75rem;
      break-inside: avoid;
      background: #fff;
      border-radius: .5rem;
      box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
    }

    figure {
      img {
        width: 100%;
        border-radius: .5rem .5rem 0 0;
        display: block;
      }

      .goods_info {
        .title {
          font-size: .875rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #3D3D3D;
          line-height: 1.375rem;
          padding: .5625rem .3125rem 0 .3125rem;
        }

        .price {
          font-size: .75rem;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #F15712;
          padding: .5625rem 0 .4375rem .3125rem;

          span {
            font-size: 1.125rem;

            display: inline-block;
          }
        }
      }
    }
  }

  ::v-deep .van-tabbar-item {
    .van-icon-home-o:before {
      content: ''
    }

    .van-icon-friends-o:before {
      content: ''
    }

    .van-icon-gift-o:before {
      content: ''
    }

    .van-icon-shop-o:before {
      content: ''
    }

    .van-icon-home-o {
      width: 1.5rem;
      height: 1.375rem;
      background: url('../../assets/images/home.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-friends-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/my.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-gift-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/2_1.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-shop-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/1_2.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }
  }

  ::v-deep .van-tabbar-item--active {
    .van-icon-home-o:before {
      content: ''
    }

    .van-icon-home-o {
      width: 1.5rem;
      height: 1.375rem;
      background: url('../../assets/images/on_home.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-friends-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/on_my.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-gift-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/2_2.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-icon-shop-o {
      width: 1.375rem;
      height: 1.375rem;
      background: url('../../assets/images/1_1.png') no-repeat;
      background-size: 100% 100%;
      display: block;
    }

    .van-tabbar-item__text {
      font-size: .625rem;
      font-family: SourceHanSansSC-Regular, SourceHanSansSC;
      font-weight: 400;
      color: #000000;
    }
  }
  ::v-deep .van-empty__image {
    width: 176px;
    height: 147px;
  }

}
</style>